<?xml version="1.0" encoding="UTF-8"?>
<ui:composition template="/pages/mastertemplate/MasterPage.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	<ui:define name="content">
		<p:panel header="#{msg.tknganhang_title}">
			<h:form>
				<p:fileUpload widgetVar="fileuplaod_wgt"
					fileUploadListener="#{TaiKhoanNganHangBean.handleFileUpload}"
					mode="advanced" dragDropSupport="false" update=":tknganhangForm"
					sizeLimit="100000" fileLimit="1"
					allowTypes="/(\.|\/)(#{DataConfigBean.fileExtensionPattern})$/" />
			</h:form>
			<h:form>
				<p:commandButton style="width:150px;float: left;margin-top:10px;"
					value="#{msg.Button_export}"
					actionListener="#{TaiKhoanNganHangBean.downloadFileCSV}"
					ajax="false">
					<p:fileDownload value="#{TaiKhoanNganHangBean.file}" />
				</p:commandButton>
			</h:form>

			<h:form id="tknganhangForm">
				<p:growl id="growforFile" autoupdate="true"
					life="#{DataConfigBean.growlShow}" />
				<p:dataTable id="dataTable" var="tknganhang"
					value="#{TaiKhoanNganHangBean.tknganhangModel}" lazy="true"
					paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,20,50,100"
					style="width: 100%; margin: 45px auto;">

					<f:facet name="header">
						<h:outputText value="#{msg.danhsachtknganhang}"
							styleClass="tableHeader" />
						<div style="margin: -4px -11px 5px; float: right;">
							<p:commandButton style="height: 25px"
								update=":addtknganhangForm:display" value="+ thêm mới"
								rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
								actionListener="#{TaiKhoanNganHangBean.notifyAdd}"
								onclick="PF('tknganhangDialog').show();">
							</p:commandButton>
						</div>

					</f:facet>

					<p:column headerText="#{msg.soTaiKhoan}">#{tknganhang.soTaiKhoan}  </p:column>

					<p:column headerText="#{msg.nganhang}">  #{tknganhang.tenNganHang}   </p:column>

					<p:column headerText="#{msg.chiNhanh}">  #{tknganhang.chiNhanh}   </p:column>

					<p:column style="width:60px;text-align: center;"
						headerText="#{msg.table_actions}">
						<p:commandButton styleClass="smallButton"
							icon="ui-icon ui-icon-pencil" update=":addtknganhangForm:display"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							action="#{TaiKhoanNganHangBean.notifyEdit(tknganhang)}"
							oncomplete="PF('tknganhangDialog').show();">

						</p:commandButton>
						<p:commandButton style="margin-left: 5px" styleClass="smallButton"
							icon="ui-icon ui-icon-trash"
							rendered="#{UserBean.getAccessLevel() == 'WRITE'}"
							oncomplete="PF('confirmRemove').show();">
							<f:setPropertyActionListener value="#{tknganhang}"
								target="#{TaiKhoanNganHangBean.selectedtknganhang}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>

				<p:dialog id="confirmRemove" header="#{msg.confirm}"
					widgetVar="confirmRemove" resizable="false">
					<table>
						<tr>
							<td><h:outputText value="#{msg.confirm_text}:" /></td>
							<td align="right"><p:commandButton value="#{msg.okButton}"
									actionListener="#{TaiKhoanNganHangBean.removetknganhang}"
									update=":tknganhangForm" oncomplete="PF('confirmRemove').hide();" /></td>
						</tr>

					</table>
				</p:dialog>
			</h:form>
			<h:form id="addtknganhangForm">
				<p:dialog id="dialog" header="Thêm mới/ Sửa" modal="true"
					widgetVar="tknganhangDialog" resizable="false">

					<p:panel id="display">
						<table>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										for="sotaikhoan" value="#{msg.soTaiKhoan}" /></td>
								<td><p:inputText styleClass="inputText" required="true"
										requiredMessage="#{msg.soTaiKhoan}: #{msg.valuerequired}"
										id="sotaikhoan"
										value="#{TaiKhoanNganHangBean.tknganhang.soTaiKhoan}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.tentknganhang}" /></td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{TaiKhoanNganHangBean.tknganhang.tenNganHang}">
										<f:selectItems value="#{NganHangBean.listNganHang}"
											var="selectItem" itemLabel="#{selectItem.tenDayDu}"
											itemValue="#{selectItem.tenDayDu}" />
									</p:selectOneMenu></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.chiNhanh}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{TaiKhoanNganHangBean.tknganhang.chiNhanh}">

									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.diaChiNoiMo}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{TaiKhoanNganHangBean.tknganhang.diaChiNoiMo}">
									</p:inputText></td>
							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.ghiChu}" /></td>
								<td><p:inputText styleClass="inputText"
										value="#{TaiKhoanNganHangBean.tknganhang.ghiChu}">
									</p:inputText></td>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.loaiTaiKhoanNganHang}" /></td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{TaiKhoanNganHangBean.tknganhang.loaiTaiKhoanNganHang}"
										valueChangeListener="#{TaiKhoanNganHangBean.loaiTaiKhoanChange}">
										<f:selectItems
											value="#{TaiKhoanNganHangBean.listLoaiTKNganHang}"
											var="selectItem" itemLabel="#{selectItem}"
											itemValue="#{selectItem}" />
										<p:ajax
											event="change" update=":addtknganhangForm:display">
										</p:ajax>
									</p:selectOneMenu></td>

							</tr>
							<tr>
								<td><p:outputLabel style="margin-left: 20px"
										value="#{msg.doiTac}" id="doitacLabel"
										rendered="#{TaiKhoanNganHangBean.taiKhoaiDoiTac}" /></td>
								<td><p:selectOneMenu styleClass="inputText"
										value="#{TaiKhoanNganHangBean.tknganhang.doiTac}"
										id="doitacSelect"
										rendered="#{TaiKhoanNganHangBean.taiKhoaiDoiTac}">
										<f:selectItems
											value="#{DoiTacBean.listDoiTac}"
											var="selectItem" itemLabel="#{selectItem.tenDoiTac}"
											itemValue="#{selectItem.maDoiTac}" />
									</p:selectOneMenu></td>
								<td></td>
								<td></td>

							</tr>
							<tr>
								<td></td>
								<td></td>

								<td></td>
								<td align="right"><p:commandButton value="Lưu"
										actionListener="#{TaiKhoanNganHangBean.save}"
										update=":tknganhangForm :addtknganhangForm:display"
										oncomplete="if(args.opSuccess) PF('tknganhangDialog').hide()"></p:commandButton></td>
							</tr>
						</table>
					</p:panel>
				</p:dialog>
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
